﻿using System;
using Autodesk.Revit.DB;
using YJKArchMethodLibrary.Utils;
using YJKElementFinish.ColumnSurface.Managers;

namespace YJKElementFinish.ColumnSurface.DataDefinition
{
	public class WallLayerInfos
	{
		public CompoundStructureLayer StructureLayer { get; set; }

		public string Name { get; set; }

		public string MaterialName { get; set; }

		public string Thickness { get; set; }

		public WallLayerInfos(WallLayerInfos other)
		{
			this.StructureLayer = other.StructureLayer;
			this.Name = other.Name;
			this.MaterialName = other.MaterialName;
			this.Thickness = other.Thickness;
		}

		public WallLayerInfos DeepClone()
		{
			CompoundStructureLayer structureLayer = null;
			if (this.StructureLayer != null)
			{
				structureLayer = new CompoundStructureLayer(this.StructureLayer);
			}
			return new WallLayerInfos(structureLayer, this.Name, this.MaterialName, this.Thickness);
		}

		public WallLayerInfos(CompoundStructureLayer structureLayer, string layerName, string materialName, string thickness)
		{
			this.StructureLayer = structureLayer;
			this.Name = layerName;
			this.MaterialName = materialName;
			this.Thickness = thickness;
		}

		public void Update(Document doc)
		{
			if (this.StructureLayer == null)
			{
				return;
			}
			this.StructureLayer.Function = WallTypeManager.GetLayerMaterialFunctionByName(this.Name);
			this.StructureLayer.MaterialId = WallTypeManager.GetMaterialIdByName(this.MaterialName, doc);
			double val = Convert.ToDouble(this.Thickness);
			this.StructureLayer.Width = Common.MMToFeet(val);
		}
	}
}
